﻿Public Class TMyTableColumn
    Friend _TableCatalog As String
    Friend _TableSchema As String
    Friend _TableName As String
    Friend _ColumnName As String
    Friend _OrdinalPosition As Integer
    Friend _ColumnDefault As String
    Friend _IsNullable As String
    Friend _DataType As String
    Friend _CharacterMaximumLength As Integer
    Friend _CharacterOctetLength As Integer
    Friend _NumericPrecision As Integer
    Friend _NumericScale As Integer
    Friend _CharacterSetName As String
    Friend _CollationName As String
    Friend _ColumnType As String
    Friend _ColumnKey As String
    Friend _Extra As String
    Friend _Privileges As String
    Friend _ColumnComment As String

    Public ReadOnly Property IsString() As Boolean
        Get
            Dim s As String = _DataType.ToUpper
            If s.Equals("VARCHAR") Then
                Return True
            ElseIf s.Equals("CHAR") Then
                Return True
            ElseIf s.Equals("TEXT") Then
                Return True
            ElseIf s.Equals("TINYTEXT") Then
                Return True
            ElseIf s.Equals("MEDIUMTEXT") Then
                Return True
            ElseIf s.Equals("LONGTEXT") Then
                Return True
            ElseIf s.Equals("BINARY") Then
                Return True
            ElseIf s.Equals("VARBINARY") Then
                Return True
            ElseIf s.Equals("TINYBLOB") Then
                Return True
            ElseIf s.Equals("BLOB") Then
                Return True
            ElseIf s.Equals("MEDIUMBLOB") Then
                Return True
            ElseIf s.Equals("LONGBLOB") Then
                Return True
            Else
                Return False
            End If

        End Get
    End Property
    Public ReadOnly Property DataLength() As String
        Get
            If _ColumnType.Contains("(") Then
                Dim sTmp1 As String() = _ColumnType.Split("(")
                Dim s1 As String = sTmp1(1)
                Dim sTmp2 As String() = s1.Split(")")
                Return sTmp2(0)
            Else
                Return String.Empty
            End If
        End Get
    End Property

    Public ReadOnly Property Attribute() As String
        Get
            If _ColumnType.Contains("unsigned zerofill") Then
                Return "unsigned zerofill"
            ElseIf _ColumnType.Contains("unsigned") Then
                Return "unsigned"
            ElseIf _Extra.Contains("on update CURRENT_TIMESTAMP") Then
                Return "on update CURRENT_TIMESTAMP"
            Else
                Return String.Empty
            End If
        End Get
    End Property

    Public ReadOnly Property AutoIncrement() As Boolean
        Get
            Return _Extra.Contains("auto_increment")
        End Get
    End Property

    Public ReadOnly Property TableCatalog() As String
        Get
            Return _TableCatalog
        End Get
    End Property

    Public ReadOnly Property TableSchema() As String
        Get
            Return _TableSchema
        End Get
    End Property

    Public ReadOnly Property TableName() As String
        Get
            Return _TableName
        End Get
    End Property

    Public ReadOnly Property ColumnName() As String
        Get
            Return _ColumnName
        End Get
    End Property

    Public ReadOnly Property OrdinalPosition() As Integer
        Get
            Return _OrdinalPosition
        End Get
    End Property

    Public ReadOnly Property ColumnDefault() As String
        Get
            Return _ColumnDefault
        End Get
    End Property

    Public ReadOnly Property IsNullable() As String
        Get
            Return _IsNullable
        End Get
    End Property

    Public ReadOnly Property DataType() As String
        Get
            Return _DataType
        End Get
    End Property

    Public ReadOnly Property CharacterMaximumLength() As Integer
        Get
            Return _CharacterMaximumLength
        End Get
    End Property

    Public ReadOnly Property CharacterOctetLength() As Integer
        Get
            Return _CharacterOctetLength
        End Get
    End Property

    Public ReadOnly Property NumericPrecision() As Integer
        Get
            Return _NumericPrecision
        End Get
    End Property

    Public ReadOnly Property NumericScale() As Integer
        Get
            Return _NumericScale
        End Get
    End Property

    Public ReadOnly Property CharacterSetName() As String
        Get
            Return _CharacterSetName
        End Get
    End Property

    Public ReadOnly Property CollationName() As String
        Get
            Return _CollationName
        End Get
    End Property

    Public ReadOnly Property ColumnType() As String
        Get
            Return _ColumnType
        End Get
    End Property

    Public ReadOnly Property ColumnKey() As String
        Get
            Return _ColumnKey
        End Get
    End Property

    Public ReadOnly Property Extra() As String
        Get
            Return _Extra
        End Get
    End Property

    Public ReadOnly Property Privileges() As String
        Get
            Return _Privileges
        End Get
    End Property

    Public ReadOnly Property ColumnComment() As String
        Get
            Return _ColumnComment
        End Get
    End Property

End Class
